<template>
	<view>
    <text style="padding: 20px;font-size: 20px">选择文件：{{imgFileByte.name}}</text>
    <u--image :showLoading="true" :src="imgSrc" width="80px" height="80px" @click="selectimg"></u--image>
<!--    <button @click="selectimg">选择图片</button>-->
<!--    <button @click="post">测试上传</button>-->
    <u-button type="success" class="u-button--success" @click="selectimg" style="margin: 10px 0" text="选择图片"></u-button>
    <u-button type="primary" class="u-button--success" @click="post" text="提交上传"></u-button>
	</view>
</template>

<script>
	import request from "@/utils/request";
  export default {
    data(){
      return {
        imgFileByte: {}
      }
    },
    computed:{
      imgSrc(){
        return (this.imgFileByte instanceof File) ? URL.createObjectURL(this.imgFileByte):''
      }
    },
		methods: {

      selectimg(){
        uni.chooseImage({
          success: (chooseImageRes) => {
            this.imgFileByte = chooseImageRes.tempFiles[0];
          }
        });
      },
        post(){
            request.requestFormData({
              url:'/store/apply',
              data:{
                'thumb[0]':this.imgFileByte,
                'thumb[1]':this.imgFileByte,
                'business_license[]':this.imgFileByte,
                'imgs[]':this.imgFileByte,
                'licence[]':this.imgFileByte,
                lat:29.000,
                lng:109.000,
                phone:13883850000,
                charge_phone:13883850000,
                area_id:110000,
                business_hours:'周一至周五 8:00-20:00',
                address:'重庆重庆市渝中区大坪正街160号16-3',
                title:'cs'
              }
            }).then((msg)=>{
              uni.showModal({
                title:'响应提示',
                content:msg.msg,
                showCancel:false
              })
            })

        }
		}
	}
</script>

<style>
	
</style>
